package org.wsjy.service;

import java.util.UUID;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.wsjy.mapper.TCultureMapper;
import org.wsjy.model.TCulture;

import org.wsjy.util.DateUtil;
/**
 * 
 *@Title:
 *@Company:万世极缘工作室
 *@Description:
 *@Author:万世极缘
 *@Since:2016年2月16日
 *@Copyright:Copyright (c) 2016
 *@ModifyDate:
 *@Version:1.1.0
 */
@Service("cultureService")
@Transactional
public class CultureService {
    @Autowired
    private TCultureMapper cultureMapper;
    
    public TCulture getNewest(){
        return cultureMapper.getNewest();
    }

    /**
     * 保存到数据库，如果没有stId,表示要新增
     * 有stId表示要修改
     * @param culture
     * @Description:
     */
    public void save(TCulture culture) {
        if(StringUtils.isEmpty(culture.getStId())){
            culture.setStId(UUID.randomUUID().toString());
            culture.setDtCreateTime(DateUtil.getNow());
            cultureMapper.insert(culture);
        }else{
            culture.setDtUpdateTime(DateUtil.getNow());
            cultureMapper.updateByPrimaryKeyWithBLOBs(culture);
        }
    }
}
